#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
//int main()
//{
//	char arr1[20] = "abcdef";
//	char arr2[] = "****";
//	printf("%s", strncpy(arr1, arr2, 3));
//	return 0;
//}

//int main()
//{
//	char arr1[10] = "abcdef";
//	char arr2[] = "****";
//	printf("%s", strncpy(arr1, arr2, 6));//err
//	return 0;
//}

//int main()
//{
//	char arr[20] = "abcdef\0oooooo";
//	char arr2[] = "*****";
//	printf("%s\n", strncat(arr, arr2, 4));
//	return 0;
//}

//int main()
//{
//	char arr[20] = "abc";
//	printf("%s\n", strncat(arr, arr, 3));
//	return 0;
//}

//int main()
//{
//	int ret = strncmp("abcdef", "abcd", 3);
//	printf("%d", ret);
//	return 0;
//}

#include <assert.h>

char* my_strstr(const char* str1, const char* str2)
{
	assert(str1 && str2);
	const char* s1 = str1;
	const char* s2 = str2;
	const char* p = str1;
	while (*p)
	{
		s1 = p;
		s2 = str2;
		while ((*s1 != '\0') && (*s2 != '\0') && (*s1 == *s2))
		{
			s1++;
			s2++;
		}
		if (*s2 == '\0')
			return (char*)p;
		p++;
	}
	return NULL;
}

int main()
{
	char arr[] = "abcdef";
	char arr2[] = "cde";
	char* p = my_strstr(arr, arr2);
	printf("%s", p);
	return 0;
}